package common.util;

import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @author ranhongmin
 * @date 2017/11/16
 * Description:出票的 批量插入都可以用
 */
public class MapperThreadUtil<K extends Mapper, V extends List> implements Runnable {

	private K k;
	private V v;
	private int start;
	private int end;

	/**
	 * When an object implementing interface <code>Runnable</code> is used
	 * to create a thread, starting the thread causes the object's
	 * <code>run</code> method to be called in that separately executing
	 * thread.
	 * <p>
	 * The general contract of the method <code>run</code> is that it may
	 * take any action whatsoever.
	 *
	 * @see Thread#run()
	 */
	@Override
	public void run() {
		for (int i = start; i < end; i++) {
			k.insertSelective(v.get(i));
		}
	}

	public MapperThreadUtil(Mapper tMapper, List tList, int start, int end) {
		this.k = (K) tMapper;
		this.v = (V) tList;
		this.start = start;
		this.end = end;
	}


}
